/**
 * futures : masterlink.futures.dao.AccountDao.java
 */
package masterlink.futures.dao;

import java.util.List;

import masterlink.futures.vo.CPRate;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/10/25
 * @version 1.0.0	
 */
@Repository
@Qualifier("CPRateDao")
public class CPRateDao extends TimesTenTemplateDao {
	
	private static final String FIND_BY_DATE="select a.date1 as \"date\",e.stockidx,e.futuresidx,"+
												" a.qtybuy as \"fitx_qtybuy\", a.qtysell as \"fitx_qtysell\", a.qtyratio as \"fitx_qtyratio\","+
												" a.accountbuy as \"fitx_accbuy\", a.accountsell as \"fitx_accsell\", a.accountratio as \"fitx_accratio\","+
												" b.qtybuy as \"fimtx_qtybuy\", b.qtysell as \"fimtx_qtysell\", b.qtyratio as \"fimtx_qtyratio\","+
												" b.accountbuy as \"fimtx_accbuy\", b.accountsell as \"fimtx_accsell\", b.accountratio as \"fimtx_accratio\","+
												" c.qtybuy as \"fite_qtybuy\", c.qtysell as \"fite_qtysell\", c.qtyratio as \"fite_qtyratio\","+
												" c.accountbuy as \"fite_accbuy\", c.accountsell as \"fite_accsell\", c.accountratio as \"fite_accratio\","+
												" d.qtybuy as \"fitf_qtybuy\", d.qtysell as \"fitf_qtysell\", d.qtyratio as \"fitf_qtyratio\","+
												" d.accountbuy as \"fitf_accbuy\", d.accountsell as \"fitf_accsell\", d.accountratio as \"fitf_accratio\""+
												" from futmat a,futmat b,futmat c,futmat d,marketindex e"+
												" where a.date1=b.date1 and a.tag1=b.tag1"+
												" and b.date1=c.date1 and b.tag1=c.tag1"+
												" and c.date1=d.date1 and c.tag1=d.tag1"+
												" and c.date1=e.date1(+)"+
												" and a.trid='FITX'"+
												" and b.trid='FIMTX'"+
												" and c.trid='FITE'"+
												" and d.trid='FITF'"+
												" and a.tag1=?"+
												" and a.date1>=? and a.date1<=?"+
												" order by a.date1 desc";
	
	public List<CPRate> findByDate(String tag,Long start,Long end){
		return findBySql(FIND_BY_DATE, CPRate.class,tag,start,end);
	}
	
}
